<template>
    <div>
    <div>
        <h2>添加用户</h2>
        <p>用户名：<input type="text" v-model="username"></p>
        <p>密码：<input type="text" v-model="password"></p>
        <p>确认密码：<input type="text" v-model="password1"></p>
        <p>手机：<input type="text" v-model="phone"></p>
        <p>email：<input type="text" v-model="email"></p>
        <p><input type="button" @click="adduser" value="添加用户信息"></p>    
    </div>
    <div v-if="is_ok=1">
        <h2>展示当前用户信息</h2>
        <tr>
            <td>usernmae</td>
            <td>password</td>
            <td>phone</td>
            <td>email</td>
        </tr>
        <tr>
            <td>{{username}}</td>
            <td>{{password}}</td>
            <td>{{phone}}</td>
            <td>{{email}}</td>
        </tr>
    </div>
    </div>    
</template>

<script>
import {adduser} from "../axios_api/api.js"
export default {
    name:"adduser",
    data() {
        return {
            username:"",
            password:"",
            password1:"",
            phone:"",
            email:"",
            is_ok:0,
        }
    },
    methods:{
        adduser(){
            var data = {
                "username":this.username,
                "password":this.password,
                "phone":this.phone,
                "email":this.email,
            }
            adduser(data).then(res=>{
                console.log(res)
                is_ok=1
            })
        }
    }
}
</script>

<style>

</style>
